package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookInstanceObsoleted;
import com.pgybook.db.entity.domain.BookInstanceObsoletedEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookInstanceObsoletedMapper {
    int countByExample(BookInstanceObsoletedEx example);

    int deleteByExample(BookInstanceObsoletedEx example);

    @Delete({
            "delete from bookinstanceobsoleted",
            "where INSTANCEID = #{instanceid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long instanceid);

    @Insert({
            "insert into bookinstanceobsoleted (LIBID, NAME, ",
            "ISBN, BOOKNO, REASON, ",
            "ORDERID, RESPSTAFF, ",
            "POSITIONCODE, CRTTIME, ",
            "CRTSTAFF, UPDTIME, ",
            "UPDSTAFF)",
            "values (#{libid,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
            "#{isbn,jdbcType=VARCHAR}, #{bookno,jdbcType=VARCHAR}, #{reason,jdbcType=INTEGER}, ",
            "#{orderid,jdbcType=BIGINT}, #{respstaff,jdbcType=INTEGER}, ",
            "#{positioncode,jdbcType=VARCHAR}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{crtstaff,jdbcType=INTEGER}, #{updtime,jdbcType=TIMESTAMP}, ",
            "#{updstaff,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "instanceid", before = false, resultType = Long.class)
    int insert(BookInstanceObsoleted record);

    int insertSelective(BookInstanceObsoleted record);

    List<BookInstanceObsoleted> selectByExample(BookInstanceObsoletedEx example);

    @Select({
            "select",
            "INSTANCEID, LIBID, NAME, ISBN, BOOKNO, REASON, ORDERID, RESPSTAFF, POSITIONCODE, ",
            "CRTTIME, CRTSTAFF, UPDTIME, UPDSTAFF",
            "from bookinstanceobsoleted",
            "where INSTANCEID = #{instanceid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    BookInstanceObsoleted selectByPrimaryKey(Long instanceid);

    int updateByExampleSelective(@Param("record") BookInstanceObsoleted record, @Param("example") BookInstanceObsoletedEx example);

    int updateByExample(@Param("record") BookInstanceObsoleted record, @Param("example") BookInstanceObsoletedEx example);

    int updateByPrimaryKeySelective(BookInstanceObsoleted record);

    @Update({
            "update bookinstanceobsoleted",
            "set LIBID = #{libid,jdbcType=INTEGER},",
            "NAME = #{name,jdbcType=VARCHAR},",
            "ISBN = #{isbn,jdbcType=VARCHAR},",
            "BOOKNO = #{bookno,jdbcType=VARCHAR},",
            "REASON = #{reason,jdbcType=INTEGER},",
            "ORDERID = #{orderid,jdbcType=BIGINT},",
            "RESPSTAFF = #{respstaff,jdbcType=INTEGER},",
            "POSITIONCODE = #{positioncode,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP},",
            "UPDSTAFF = #{updstaff,jdbcType=INTEGER}",
            "where INSTANCEID = #{instanceid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BookInstanceObsoleted record);
}
